package com.example.qqemoji;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;

import com.way.ui.emoji.EmojiKeyboard;
import com.way.ui.emoji.EmojiKeyboard.EventListener;

public class MainActivity extends Activity {
	EditText mEditEmoji;
	TextView mTxtEmoji;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		mEditEmoji = (EditText) findViewById(R.id.emoji_edittext);
		mTxtEmoji = (TextView) findViewById(R.id.emoji_textview);
		EmojiKeyboard mEmojiKeyboard = (EmojiKeyboard) findViewById(R.id.emoji_keyboard);
		mEmojiKeyboard.setEventListener(new EventListener() {

			@Override
			public void onEmojiSelected(String res) {
				// TODO Auto-generated method stub
				EmojiKeyboard.input(mEditEmoji, res);
			}

			@Override
			public void onBackspace() {
				// TODO Auto-generated method stub
				EmojiKeyboard.backspace(mEditEmoji);
			}
		});
		mEditEmoji.addTextChangedListener(new TextWatcher() {
			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
				mTxtEmoji.setText(s);
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {

			}

			@Override
			public void afterTextChanged(Editable s) {

			}
		});
	}

}
